<template lang="">
    <div>
        <el-dialog witdh="90%" title="报告列表" :close-on-click-modal="false" :visible="showDialog" @close="clickClose">
            <el-table :data="reportlsit" style="width: 100%" stripe border>
                <el-table-column type="index" label="序号" width="50"></el-table-column>
                <el-table-column prop="id" label="报告ID" width="150"></el-table-column>
                <el-table-column prop="casename" label="用例名称" width="150"></el-table-column>
                <el-table-column prop="elapsedt" label="接口响应时间(ms)" width="140" :show-overflow-tooltip="true"></el-table-column>
                <el-table-column prop label="测试时间" width="193">
                    <template slot-scope="scope">
                        <span style="margin-left: 10px">{{
                            myDate(scope.row.create_time)
                            }}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="create_user" label="执行者" width="80"></el-table-column>
                <el-table-column prop label="测试结果" width="100" fixed="right" >
                    <template slot-scope="scope">
                        <span style="margin-left: 10px">{{
                            scope.row.status == 1 ? "通过" : "失败"
                            }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="报告详情" fixed="right">
                    <template slot-scope="scope">
                        <el-tooltip class="item" effect="dark" content="详情" placement="top-start">
                            <el-button type="success" icon="el-icon-document" circle size="mini"
                                @click="clickView(scope.row.id)">
                            </el-button>
                        </el-tooltip>
                    </template>
                </el-table-column>
            </el-table>
        </el-dialog>
        <CaseReport ref="caseRep" />
    </div>
</template>

<script>
    import { getCaseReports, getPlanRecordRep } from "@/network/networks";
    import { myDate } from "@/assets/js/common";
    import CaseReport from "@/views/manage/common/CaseReport";
    export default {
        components: {
            CaseReport,
        },

        data() {
            return {
                planid: -1,
                excutnum: null,
                showDialog: false,
                reportlsit: [],
            }
        },


        methods: {
            getReports() {
                if (this.planid == -1) {
                    return;
                }
                getPlanRecordRep({
                    planid: this.planid,
                    excutnum: this.excutnum
                })
                    .then(res => {
                        if (res.code == 1) {
                            console.log(res.data)
                            this.reportlsit = res.data;
                            this.$message.success(res.msg)
                        } else {
                            thsi.$message.error(res.msg)
                        }
                    })
                    .catch(err => {
                        this.$message.error(err)
                    })
            },

            clickClose() {
                this.showDialog = false;
                this.planid = -1;
            },

            clickView(id) {
                this.$refs.caseRep.showDialog = true;
                this.$refs.caseRep.rowid = id
            },

            //格式化时间
            myDate(time) {
                return myDate(time);
            },

            passOrno(status) {
                if (status == 1) {
                    return "通过"
                } else {
                    return "不通过"
                }
            }
        },

        watch: {
            planid(val) {
                this.getReports();
            },
        },
    }
</script>
<style lang="">

</style>